﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kryptonalysis.EventArguments;

namespace Kryptonalysis
{
    /// <summary>
    /// Class to analyze encrypted Objects and determin the password. 
    /// </summary>
    public abstract class Analyzer
    {
        #region abstract methods
        /// <summary>
        /// Abstract method to detect the password.
        /// </summary>
        /// <returns></returns>
        public abstract string DetectPassword();
        #endregion

        #region protected methods
        /// <summary>
        /// Called when [analysis startet].
        /// </summary>
        protected void OnAnalysisStartet()
        {
            if (AnalysisStartet != null)
                AnalysisStartet();
        }

        /// <summary>
        /// Raises the <see cref="E:AnalysisEndet"/> event.
        /// </summary>
        /// <param name="args">The <see cref="Kryptonalysis.EventArguments.AnalysisEndedEventArgs"/> instance containing the event data.</param>
        protected void OnAnalysisEndet(AnalysisEndedEventArgs args)
        {
            if (AnalysisEndet != null)
                AnalysisEndet(args);
        }

        /// <summary>
        /// Called when [analysis processing].
        /// </summary>
        /// <param name="percentDone">The percent done.</param>
        protected void OnAnalysisProcessing(int percentDone)
        {
            if (AnalysisProcessing != null)
                AnalysisProcessing(percentDone);
        }
        #endregion

        #region Events and Delegates
        /// <summary>
        /// Handles the AnalysisStartet event.
        /// </summary>
        public delegate void AnalysisStartedEventHandler();
        /// <summary>
        /// Occurs when [analysis startet].
        /// </summary>
        public event AnalysisStartedEventHandler AnalysisStartet;

        /// <summary>
        /// Handles the AnalysisProcessing event.
        /// </summary>
        public delegate void AnalysisProcessingEventHandler(int percentDone);
        /// <summary>
        /// Occurs when [analysis processing].
        /// </summary>
        public event AnalysisProcessingEventHandler AnalysisProcessing;

        /// <summary>
        /// Handles the AnalysisEndet event.
        /// </summary>
        public delegate void AnalysisEndetEventHandler(AnalysisEndedEventArgs args);
        /// <summary>
        /// Occurs when [analysis endet].
        /// </summary>
        public event AnalysisEndetEventHandler AnalysisEndet;
        #endregion
    }
}
